package net.kazed.nextaction.context.activity;

import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import net.kazed.nextaction.R;
import net.kazed.nextaction.database.GtdContext;

public class ContextView extends LinearLayout {
	private TextView name;
   private TextView taskCount;
   
//	private SparseIntArray mTaskCountArray;

	public ContextView(android.content.Context androidContext) {
		super(androidContext);
		
        LayoutInflater vi = (LayoutInflater) androidContext.
        		getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
        vi.inflate(R.layout.context_list_item_view, this, true); 
        
		name = (TextView) findViewById(R.id.name);
		taskCount = (TextView) findViewById(R.id.number_of_tasks);
	}
	
//	public void setTaskCountArray(SparseIntArray taskCountArray) {
//		mTaskCountArray = taskCountArray;
//	}
	
	public void updateView(GtdContext context) {
//		if (mTaskCountArray != null) {
//         Integer count = 0;
//		   if (context.getId() != null) {
//	         count = mTaskCountArray.get(context.getId());
//	         if (count == null) {
//	            count = 0;
//	         }
//		   }
//			name.setText(context.getName() + " (" + count + ")");
//		} else {
//			name.setText(context.getName());
//		}
      name.setText(context.getName());
      taskCount.setText(Integer.toString(context.getNumberOfTasks()));
	}

}
